package com.example.demo.mapper;

import com.example.demo.entity.Outstorage;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OutstorageMapper {
    // 添加出库记录
    @Insert("INSERT INTO outstorage(oid, otime, oquantity, oweight, osbelong, ofee) " +
            "VALUES(#{oid}, #{otime}, #{oquantity}, #{oweight}, #{osbelong}, #{ofee})")
    int createOutstorage(Outstorage outstorage);

    // 删除出库记录
    @Delete("DELETE FROM outstorage WHERE oid = #{oid}")
    int deleteOutstorage(Integer oid);

    // 根据ID查询出库记录
    @Select("SELECT * FROM outstorage WHERE oid = #{oid}")
    Outstorage findOutstorageById(Integer oid);

    // 查询所有出库记录
    @Select("SELECT * FROM outstorage")
    List<Outstorage> findAllOutstorages();

    // 根据仓库ID查询出库记录
    @Select("SELECT * FROM outstorage WHERE osbelong = #{sid} ORDER BY oid")
    List<Outstorage> findOutstoragesByStorageId(Integer sid);

    // 更新堆存费
    @Update("UPDATE outstorage SET ofee = #{ofee} WHERE oid = #{oid}")
    int updateStorageFee(@Param("oid") Integer oid, @Param("ofee") Double ofee);
}